<?php

namespace app\admin\model\test\hld;

use think\Model;

class Subject extends Model
{
    // 表名
    protected $name = 'test_hld_subject';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'cate1'
    ];
    

    public function getAAttr($v,$d)
    {
        $answer = [
            1   => [
                'a' => '喜欢',
                'b' => '不喜欢'
            ],
            2   => [
                'a' => '能够',
                'b' => '不能够'
            ],
            3   => [
                'a' => '喜欢',
                'b' => '不喜欢'
            ]
        ];
        return $answer[$d['cate_1']]['a'];
    }

    public function getBAttr($v,$d)
    {
        $answer = [
            1   => [
                'a' => '喜欢',
                'b' => '不喜欢'
            ],
            2   => [
                'a' => '能够',
                'b' => '不能够'
            ],
            3   => [
                'a' => '喜欢',
                'b' => '不喜欢'
            ]
        ];
        return $answer[$d['cate_1']]['b'];
    }
    public function getCate1Attr($v,$d){
        return $d['cate_1'];
    }

    public function getCate_1Attr($v){
        $cate_1 = [
            1   => '活动',
            2   => '能力',
            3   => '职业'
        ];
        return $cate_1[$v];
    }

}
